import Vue from "vue";
import Router from "vue-router";
import Layout from "@/components/Layout.vue";
import Login from "@/components/accounts/Login.vue"
import register from "@/components/accounts/Register.vue";
Vue.use(Router);

export default new Router({
    mode: "history", // history 模式去除地址栏 # 号
    routes: [
        {
            path: "/",
            name: "首页",
            component: () => import("@/components/Index.vue"),
            redirect: "/index/recommend",
            children: [
                {
                    path: "/yunye/houseinfo",
                    name: "房屋信息",
                    component: () => import("@/components/indexFragments/IHouseInfo.vue"),
                },
                {
                    path: "/index/recommend",
                    name: "推荐",
                    component: () => import("@/components/indexFragments/IIndex.vue"),
                },
                {
                    path: "/index/resource",
                    name: "房源",
                    component: () => import("@/components/indexFragments/IResource.vue"),
                },
                {
                    path: "/index/puthouse",
                    name: "发布",
                    component: () => import("@/components/indexFragments/IPutHouse.vue"),
                },
                {
                    path: "/index/help",
                    name: "发布",
                    component: () => import("@/components/indexFragments/IHelp.vue"),
                },
                {
                    path: "/accounts/showOrder",
                    name: "全部订单",
                    component: () => import("@/components/accounts/order/ShowOrder.vue"),
                    meta: { requireAuth: false },
                    redirect: "/accounts/orderinfo",
                    children:[
                        {
                            path:"/accounts/orderinfo",
                            name:"订单列表",
                            component:() => import("@/components/accounts/order/OrderInfo.vue"),
                            meta: { requireAuth: false }
                        }
                    ]
                },
                {

                    path: "/account/profile",

                    path: "/accounts/showOrder",
                    name: "全部订单",
                    component: () => import("@/components/accounts/order/ShowOrder.vue"),
                },
                {
                    path: "/accounts/profile",

                    name: "个人主页",
                    component: () => import("@/components/accounts/person/Profile"),
                    meta: { requireAuth: true },
                    redirect: "/account/showinfo",
                    children: [
                        {
                            path: "/account/favorites",
                            name: "我的收藏夹",
                            component: () => import("@/components/accounts/Favorites.vue"),
                             meta: { requireAuth: true },
                        },
                        {
                            path: "/account/showinfo",
                            name: "个人信息",
                            component: () => import("@/components/accounts/person/showinfo"),
                            meta: { requireAuth: true },
                        },
                        {
                            path: "/account/infoeditor",
                            name: "信息修改",
                            component: () => import("@/components/accounts/person/infoeditor"),
                            meta: { requireAuth: true },
                        },
                        {
                            path: "/account/imageUp",
                            name: "修改头像",
                            component: () => import("@/components/accounts/person/imageUp"),
                            meta: { requireAuth: true },
                        },
                        {
                            path: "/account/countcontrol",
                            name: "修改密码",
                            component: () => import("@/components/accounts/person/countcontrol"),
                            meta: { requireAuth: true },
                        },
                        {
                            path: "/account/money",
                            name: "充值",
                            component: () => import("@/components/accounts/person/money"),
                            meta: { requireAuth: true },
                        },
                    ]
                },
            ]
        },
        {
            path: "/login",
            name: "登录",
            component: Login,
        },
        {
            path: "/register",
            name: "注册",
            component: register,

        },
        {
            path: "/admin",
            name: "admin",
            component: Layout,
            redirect: "/admin/house",
            meta: { requireAuth: true },
            children: [{
                path: "/admin/house",
                name: "house",
                component: () => import("@/components/accounts/House.vue"),
                meta: { requireAuth: true,
               
                },
            },
            {
                path: "/admin/user",
                name: "用户",
                component: Layout,
                meta: { requireAuth: true },
                children: [
                    {
                        path: "/admin/Users",
                        name: "用户列表",
                        component: () => import("@/components/accounts/Users"),
                        meta: { requireAuth: true },
                    },
                ]
            },
            {
                path: "/admin/Order",
                name: "order",
                component: () => import("@/components/accounts/Order.vue"),
                meta: { requireAuth: false },
            },
            {
                path:"/admin/test",
                name:"test",
                component: Layout,
                children: [
                    {
                        path: "/admin/houseTest",
                        name: "测试",
                        component: () => import("@/components/accounts/test"),
                        meta: { requireAuth: true },
                    },
                ]
            }
        
        ]
        },
    ],
});
